home *** CD-ROM | disk | FTP | other *** search
/ AGA Toolkit '97 / The AGA Toolkit '97.iso / programming / c / make-3.75 / amiga.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-07  |  1.9 KB  |  87 lines

  1. /* Running commands on Amiga
  2. Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
  3. This file is part of GNU Make.
  4.  
  5. GNU Make is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. GNU Make is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with GNU Make; see the file COPYING.  If not, write to
  17. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include "make.h"
  20. #include <assert.h>
  21. #include <exec/memory.h>
  22. #include <dos/dostags.h>
  23. #include <proto/exec.h>
  24. #include <proto/dos.h>
  25.  
  26. int
  27. MyExecute (argv)
  28. char ** argv;
  29. {
  30.     char * buffer, * ptr;
  31.     char ** aptr;
  32.     int len = 0;
  33.     int status;
  34.  
  35.     for (aptr=argv; *aptr; aptr++)
  36.     {
  37.     len += strlen (*aptr) + 4;
  38.     }
  39.  
  40.     buffer = AllocMem (len, MEMF_ANY);
  41.  
  42.     if (!buffer)
  43.       fatal ("MyExecute: Cannot allocate space for calling a command");
  44.  
  45.     ptr = buffer;
  46.  
  47.     for (aptr=argv; *aptr; aptr++)
  48.     {
  49.     if (((*aptr)[0] == ';' && !(*aptr)[1]))
  50.     {
  51.         *ptr ++ = '"';
  52.         strcpy (ptr, *aptr);
  53.         ptr += strlen (ptr);
  54.         *ptr ++ = '"';
  55.     }
  56.     else if ((*aptr)[0] == '@' && (*aptr)[1] == '@' && !(*aptr)[2])
  57.     {
  58.         *ptr ++ = '\n';
  59.         continue;
  60.     }
  61.     else
  62.     {
  63.         strcpy (ptr, *aptr);
  64.         ptr += strlen (ptr);
  65.     }
  66.     *ptr ++ = ' ';
  67.     *ptr = 0;
  68.     }
  69.  
  70.     ptr[-1] = '\n';
  71.  
  72.     status = SystemTags (buffer,
  73.     SYS_UserShell, TRUE,
  74.     TAG_END);
  75.  
  76.     FreeMem (buffer, len);
  77.  
  78.     if (SetSignal(0L,0L) & SIGBREAKF_CTRL_C)
  79.     status = 20;
  80.  
  81.     /* Warnings don't count */
  82.     if (status == 5)
  83.     status = 0;
  84.  
  85.     return status;
  86. }
  87.